#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;

int n, m;
int c[25], num;
ll dp[2][2][20], cnt[2][2][20];
ll dfs(bool zero, bool limit, int pos) {
  if (!pos) {
    cnt[zero][limit][pos] = 1;
    return 0;
  }
  ll& ans = dp[zero][limit][pos];
  ll& tot = cnt[zero][limit][pos];
  if (dp[zero][limit][pos] != -1) return ans;
  ans = 0, tot = 0;
  int imx = limit ? c[pos] : 9;
  rep(i, 0, imx) {
    bool czero = zero && i == 0;
    bool climit = limit && i == imx;
    ans = (ans + dfs(czero, climit, pos - 1)) % MOD;
    tot = (tot + cnt[czero][climit][pos - 1]) % MOD;
    ans = (ans + i * cnt[czero][climit][pos - 1]) % MOD;
  }
  return ans;
}
ll solve(ll n) {
  if (!n) return 0;
  num = 0;
  while (n) {
    c[++num] = n % 10;
    n /= 10;
  }
  memset(dp, -1, sizeof(dp));
  return dfs(1, 1, num);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    ll x, y;
    cin >> x >> y;
    ll res = (solve(y) + MOD - solve(x - 1)) % MOD;
    cout << res << endl;
  }
  return 0;
}